package com.kongyz;

import com.kongyz.filter.*;

import javax.naming.Name;
import java.util.ArrayList;
import java.util.List;

/**
 * @author kongyz
 * @date 2018/6/27 22:05
 * @Description:
 */
public class Demo {
    public static void main(String[] args) {
        List<Person> persons=new ArrayList<Person>();

        persons.add(new Person("张三","男","单身"));
        persons.add(new Person("小花","女","单身"));
        persons.add(new Person("李四","男","已婚"));
        persons.add(new Person("小杰","女","已婚"));
        persons.add(new Person("王二","男","单身"));
        persons.add(new Person("小丽","女","单身"));

        Criteria male=new CriteriaMale();
        Criteria female=new CriteriaFemale();
        Criteria single=new CriteriaSingle();
        Criteria singleMale=new AndCriteria(single,male);
        Criteria singleOrFemale=new OrCriteria(single,female);


        System.out.println("男性：");
        printPersons(male.meetCriteria(persons));

        System.out.println("女性：");
        printPersons(female.meetCriteria(persons));

        System.out.println("单身且是男性：");
        printPersons(singleMale.meetCriteria(persons));

        System.out.println("单身或女性");
        printPersons(singleOrFemale.meetCriteria(persons));


    }

    public static void printPersons(List<Person> personList){
        for (Person person:personList){
            System.out.println(person.getName()+"："+person.getGender()+","+person.getMeritalStatus());
        }
    }
}
